{include file="header"}
<div style="padding: 20px;" class="adminmyucms">
<form class="layui-form" action="">
  <div class="layui-form-item" >
     <span style="float: left;line-height: 38px;margin: 0 20px;">模板</span>
      <div style="width: 150px;float: left;">
       <select name="in" lay-verify="required">
        <option value=""></option>
        {foreach name="muban" item="v" key="k"}
        <option value="{$v.name}">{$v.title}</option>
        {/foreach}
        
        {foreach name="mubanw" item="vs" key="k"}
        <option value="{$vs.name}">{$vs.title}</option>
        {/foreach}
       </select>
      </div>
      <span style="float: left;line-height: 38px;margin: 0 20px;">备注</span>
	  <input type="text" name="content" value=""  placeholder="广告分类备注" autocomplete="off" lay-verify="required" class="layui-input" style="width: 300px;float: left;">
    <button style="float: left;line-height: 38px;margin: 0 20px;" class="layui-btn layui-btn-warm" lay-submit lay-filter="set-add">添加广告分类</button>
    </div>
</form>
 
{foreach name=":fun_S('adCate',array(),'id desc','1000',1)" item="vo" key="k"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$vo.id}">	
<table class="layui-table" style="width: 1200px;">
  <colgroup>
    <col width="200">
    <col width="450">
    <col width="150">
    <col width="100">
    <col width="100">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>
       <select name="in" lay-verify="required">
        <option value=""></option>
        {foreach name="muban" item="v" key="k"}
        <option value="{$v.name}" {if condition="$v.name eq $vo.in"}selected="selected"{/if}>{$v.title}</option>
        {/foreach}
        
        {foreach name="mubanw" item="vs" key="k"}
        <option value="{$vs.name}" {if condition="$vs.name eq $vo.in"}selected="selected"{/if}>{$vs.title}</option>
        {/foreach}
       </select>
      </td>
      <td><input type="text" name="content" value="{$vo.content}" placeholder="备注描述" autocomplete="off" class="layui-input"></td>
      <td>
      	<button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button>
      
      </td>
      <td>
      	<button type="button" class="layui-btn layui-btn-danger"  member-name="确定要删除这个广告分类吗?" url="{:url("set/delete")}?id={$vo.id}&m=ad_cate" lay-submit lay-filter="delete" ><i class="layui-icon">&#xe640;</i> 删除</button>
      </td>
      <td>
      	<a href="/admin.php/ad/index.html?in={$vo.in}" type="button" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe674;</i> 查看广告</a>
      </td>
    </tr>
  </tbody>
</table>
</form>
 
{/foreach}
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;

  //更新
  form.on('submit(set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("ad/updatecate")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //添加
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("ad/insertcate")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
</script>
</div>  
{include file="footer"}